<script>
	import Header from "@/components/Header.vue"
	export default {
		components: {
			Header
		},
		data() {
			return {
				payType: 0,
				title: "实名认证",
				flag:0,
				me_realname:'',
				me_realidcard:''
			}
		},
		onLoad(options) {
			var info = uni.getStorageSync('info')
			console.log(info)
			this.me_realname = info.me_realname
			this.me_realidcard = info.me_realidcard
		},
		methods: {
			renzheng(){
				var that = this
				uni.request({
					url:getApp().globalData.host+'/api/My/switchRealName',
					data: {
						me_realname:that.me_realname,me_realidcard:that.me_realidcard
					},
					header: {
						memberid:uni.getStorageSync('member_id'),
						membertoken:uni.getStorageSync('member_token'),
					},
					success:(r) => {
						if(r.data.code!=200){
							uni.showModal({
								content:r.data.msg
							})
							if(r.data.msg=='您已经通过了实名认证'){
								setTimeout(function(){
									uni.navigateBack({ delta: 1 })
								},2000)
							}
							
						}else{
							that.flag=1
							
							uni.request({
								url:getApp().globalData.host+'/api/My/getMyInfo',
								header: {
									memberid:uni.getStorageSync('member_id'),
									membertoken:uni.getStorageSync('member_token'),
								},
								success:(rr) => {
									uni.setStorageSync('info',rr.data.data)
								},
							})
							
						}
					},
				})
			}
		}
	}
</script>
<template>
	<view class="custom-bg">

		<Header :title="title" />
		<!-- 表单 -->
		<div class="bg-white" v-if="flag==0">
			<div class="between px-30 py-45">
				<div class="fz30 text-gray-29 flex-shirnk-0 mr-30">真实姓名</div>
				<input type="text" class="w-full" placeholder="请输入真实姓名" v-model="me_realname">
			</div>
			<div class="line"></div>
			<div class="between px-30 py-45">
				<div class="fz30 text-gray-29 flex-shirnk-0 mr-30">证件类型</div>
				<picker mode="selector" :range="['身份证']" class="w-full">
					<view>身份证</view>
				</picker>
			</div>
			<div class="line"></div>
			<div class="between px-30 py-45">
				<div class="fz30 text-gray-29 flex-shirnk-0 mr-30">证件号码</div>
				<input type="text" class="w-full" placeholder="请输入证件号码" v-model="me_realidcard">
			</div>
		</div>
		
		<!-- 认证成功 -->
		<div class="center flex-col" style="margin-top: 200rpx;" v-if="flag==1">
			<div class="avatar-group relative">
				<image src="/static/my/avatar-bg.png" mode="widthFix" class="absolute l-0 t-0 z-10"
					style="width: 328rpx;left:-80rpx">
				</image>
				<image src="../../../static/logp.png" mode="aspectFill" class="w-180 h-180 rounded-full"></image>
			</div>
			<div class="fz40 mt-50 text-gray-37">
				实名认证成功
			</div>

			<div class="fz30 text-gray-a7 mt-10 mb-50">实名认证成功后将无法更改</div>

			<div class="px-30 w-full">
				<div class="flex-col text-gray-a7 w-full rounded-15 p-40" style="background-color: #F4F7FF;">
					<div class="fz30 mb-20">姓名： <text class="text-gray-29">{{me_realname}}</text> </div>
					<div class="fz30">身份证号：<text class="text-gray-29">{{me_realidcard}}</text></div>
				</div>
			</div>

		</div>
		<!-- 认证成功 -->


		<!-- 判断看自己要隐藏按钮 -->
		<div class="submit  text-white p-30 bg-white">
			<div class="bg-purple center h-90 rounded-50" @click="renzheng()">
				提交认证
			</div>
		</div>

		<div class="h-150"></div>
	</view>


</template>



<style>
	.avatar-group {
		position: relative;
	}

	page {
		height: 100%;
		background-color: #F8F8F8;
	}

	.submit {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}
</style>